commonlibsse_ng\re\m/
MagicItem.rs

1use crate::re::Actor::Actor;
2use crate::re::ActorValues::{ActorValue, ActorValue_CEnum};
3use crate::re::BGSKeywordForm::{BGSKeywordForm, BGSKeywordFormVtbl};
4use crate::re::BSTArray::BSTArray;
5use crate::re::BSTSmartPointer::BSTSmartPointer;
6use crate::re::TESBoundObject::{TESBoundObject, TESBoundObjectVtbl};
7use crate::re::TESFile::TESFile;
8use crate::re::TESFullName::TESFullName;
9use crate::re::TESModel::TESModel;
10use crate::re::TESObjectWEAP::TESObjectWEAP;
11use crate::re::offsets_rtti::RTTI_MagicItem;
12use crate::re::offsets_vtable::VTABLE_MagicItem;
13use crate::re::{EffectItem, EffectSetting};
14use crate::re::{MagicSystem, QueuedFile};
15use crate::rel::id::VariantID;
16
17#[repr(C)]
18#[derive(Debug)]
19pub struct MagicItem {
20    pub __base: TESBoundObject,                   // 0x00
21    pub __base1: TESFullName,                     // 0x30
22    pub __base2: BGSKeywordForm,                  // 0x40
23    pub effects: BSTArray<*mut EffectItem>,       // 0x58
24    pub hostileCount: i32,                        // 0x70
25    pub pad74: u32,                               // 0x74
26    pub avEffect: *mut EffectSetting,             // 0x78
27    pub preloadCount: u32,                        // 0x80
28    pub pad84: u32,                               // 0x84
29    pub preloadItem: BSTSmartPointer<QueuedFile>, // 0x88
30}
31const _: () = assert!(core::mem::size_of::<MagicItem>() == 0x90);
32
33impl MagicItem {
34    pub const RTTI: VariantID = RTTI_MagicItem;
35    pub const VTABLE: [VariantID; 3] = VTABLE_MagicItem;
36}
37
38#[repr(C)]
39pub struct MagicItemVtbl {
40    // Base class vtables (TESBoundObject, BGSKeywordForm) should come first
41    pub __base: TESBoundObjectVtbl,
42    pub __base1: BGSKeywordFormVtbl,
43
44    // MagicItem virtual methods (start offset: 0x53 * 8 = 664)
45    pub GetSpellType: extern "C" fn(this: *const MagicItem) -> MagicSystem::SpellType, // 0x53
46    pub SetCastingType: extern "C" fn(this: *mut MagicItem, ty: MagicSystem::CastingType), // 0x54 - { return; }
47    pub GetCastingType: extern "C" fn(this: *const MagicItem) -> MagicSystem::CastingType_CEnum, // 0x55
48    pub SetDelivery: extern "C" fn(this: *mut MagicItem, delivery: MagicSystem::Delivery), // 0x56 - { return; }
49    pub GetDelivery: extern "C" fn(this: *const MagicItem) -> MagicSystem::Delivery_CEnum, // 0x57
50    pub IsValidDelivery:
51        extern "C" fn(this: *const MagicItem, delivery: MagicSystem::Delivery) -> bool, // 0x58 - { return true; }
52    pub GetFixedCastDuration: extern "C" fn(this: *const MagicItem) -> f32, // 0x59 - { return 0.0; }
53    pub GetRange: extern "C" fn(this: *const MagicItem) -> f32, // 0x5A - { return 0.0; }
54    pub IgnoresResistance: extern "C" fn(this: *const MagicItem) -> bool, // 0x5B - { return false; }
55    pub IgnoreLOS: extern "C" fn(this: *const MagicItem) -> bool, // 0x5C - { return false; }
56    pub IsFood: extern "C" fn(this: *const MagicItem) -> bool,    // 0x5D - { return false; }
57    pub GetNoAbsorb: extern "C" fn(this: *const MagicItem) -> bool, // 0x5E - { return false; }
58    pub GetNoDualCastModifications: extern "C" fn(this: *const MagicItem) -> bool, // 0x5F - { return false; }
59    pub GetSkillUsageData: extern "C" fn(this: *const MagicItem, data: *mut SkillUsageData) -> bool, // 0x60 - { return false; }
60    pub IsPoison: extern "C" fn(this: *const MagicItem) -> bool, // 0x61 - { return GetSpellType() == MagicSystem::SpellType::kPoison; }
61    pub IsMedicine: extern "C" fn(this: *const MagicItem) -> bool, // 0x62 - { return false; }
62    pub AdjustCost: extern "C" fn(this: *const MagicItem, cost: *mut f32, actor: *mut Actor), // 0x63 - { return; }
63    pub GetChargeTime: extern "C" fn(this: *const MagicItem) -> f32, // 0x64 - { return 0.0; }
64    pub GetMaxEffectCount: extern "C" fn(this: *const MagicItem) -> u32, // 0x65 - { return 0; }
65    pub GetAssociatedSkill: extern "C" fn(this: *const MagicItem) -> ActorValue_CEnum, // 0x66 - { return ActorValue::kNone; }
66    pub IsTwoHanded: extern "C" fn(this: *const MagicItem) -> bool, // 0x67 - { return false; }
67    pub GetChunkID: extern "C" fn(this: *mut MagicItem) -> u32,     // 0x68
68    pub CopyMagicItemData: extern "C" fn(this: *mut MagicItem, src: *const MagicItem), // 0x69
69    pub LoadMagicItemChunk:
70        extern "C" fn(this: *mut MagicItem, mod_file: *mut TESFile, chunk_id: u32), // 0x6A - { return; }
71    pub LoadChunkDataPostProcess: extern "C" fn(this: *mut MagicItem, mod_file: *mut TESFile), // 0x6B - { return; }
72    pub GetData1: extern "C" fn(this: *const MagicItem) -> *const Data, // 0x6C
73    pub GetData2: extern "C" fn(this: *mut MagicItem) -> *mut Data,     // 0x6D
74    pub GetDataSize: extern "C" fn(this: *const MagicItem) -> u32,      // 0x6E
75    pub InitFromChunk: extern "C" fn(this: *mut MagicItem, mod_file: *mut TESFile), // 0x6F
76    pub InitChunk: extern "C" fn(this: *mut MagicItem),                 // 0x70
77}
78const _: () = {
79    const VTABLE_SIZE: usize = core::mem::size_of::<MagicItemVtbl>();
80    const EXPECTED_SIZE: usize = 0x71 * core::mem::size_of::<usize>();
81    // assert!(VTABLE_SIZE == EXPECTED_SIZE); // FIXME: pass assertion
82};
83
84#[repr(C)]
85#[derive(Debug)]
86pub struct PreloadableVisitor {
87    vtable: *const PreloadableVisitorVtbl,
88}
89const _: () = assert!(core::mem::size_of::<PreloadableVisitor>() == 0x08);
90
91#[repr(C)]
92pub struct PreloadableVisitorVtbl {
93    pub VisitModel: extern "C" fn(this: *mut PreloadableVisitor, model: *mut TESModel),
94    pub VisitWeapon: extern "C" fn(this: *mut PreloadableVisitor, weapon: *mut TESObjectWEAP),
95}
96
97#[repr(C)]
98#[derive(Debug)]
99pub struct SkillUsageData {
100    effect: *mut EffectItem, // 0x00
101    skill: ActorValue,       // 0x08
102    magnitude: f32,          // 0x0C
103    custom: bool,            // 0x10
104    pad11: u8,               // 0x11
105    pad12: u16,              // 0x12
106    pad14: u32,              // 0x14
107}
108const _: () = assert!(core::mem::size_of::<SkillUsageData>() == 0x18);
109
110#[repr(C)]
111#[derive(Debug)]
112pub struct Data {
113    costOverride: i32, // 0x0
114    flags: u32,        // 0x4
115}
116const _: () = assert!(core::mem::size_of::<Data>() == 0x8);